/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.midlet.*;

/**
 * @author USER
 */
public class Animation extends MIDlet 
implements CommandListener {

    private Display display;
    private AnimationCanvas canvas;
    private Command cmdExit;
    
    public Animation()
    {
        display = Display.getDisplay(this);
        cmdExit = new Command("Exit", 
                Command.EXIT, 1);
        if((canvas = new AnimationCanvas()) != null)
        {
            canvas.addCommand(cmdExit);
            canvas.setCommandListener(this);
        }
    }
    
    public void startApp() {
        if (canvas != null)
        {
            display.setCurrent(canvas);
            canvas.start();
        }
    }
    
    public void pauseApp() {
    }
    
    public void destroyApp(boolean unconditional) {
        canvas.stop();
    }

    public void commandAction(Command c, Displayable d) {
        if(c == cmdExit)
        {
            destroyApp(true);
            notifyDestroyed();
        }
    }
}
